<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <label class="el-form-item-label">载盘编码</label>
        <el-input
          v-model="query.palletCode"
          clearable
          placeholder="载盘编码"
          style="width: 185px;"
          class="filter-item"
          @keyup.enter.native="crud.toQuery"
        />
        <label class="el-form-item-label">任务编码</label>
        <el-input
          v-model="query.missionCode"
          clearable
          placeholder="任务编码"
          style="width: 185px;"
          class="filter-item"
          @keyup.enter.native="crud.toQuery"
        />
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表格渲染-->
      <el-table
        ref="table"
        v-loading="crud.loading"
        :data="crud.data"
        size="small"
        style="width: 100%;"
        @selection-change="crud.selectionChangeHandler"
      >
        <el-table-column type="selection" width="55" />
        <el-table-column prop="missionCode" label="任务编码" />
        <el-table-column prop="palletCode" label="载盘编码" />
        <el-table-column prop="missionStatus" label="任务状态">
          <!-- <template slot-scope="scope">
            {{ dict.label.outbound_task_type[scope.row.missionStatus] }}
          </template> -->
        </el-table-column>
        <el-table-column prop="source" label="起点" />
        <el-table-column prop="destination" label="终点" />
        <el-table-column prop="createTime" label="创建时间" />
        <!-- <el-table-column prop="startTime" label="开始时间" /> -->
        <el-table-column prop="finishTime" label="结束时间" />
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { id: null, palletCode: null, missionStatus: null, source: null, destination: null, createTime: null, startTime: null, finishTime: null, missionCode: null }
export default {
  name: 'InBoundMissionHistory',
  components: { pagination, crudOperation, rrOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['outbound_task_type'],
  cruds() {
    return CRUD({
      title: '入库历史任务', url: 'api/inBoundMissionHistory', idField: 'id', sort: 'id,desc',
      optShow: {
        add: false,
        edit: false,
        del: false,
        download: true,
        reset: true
      }, crudMethod: {}
    })
  },
  data() {
    return {
      permission: {
        add: ['admin', 'inBoundMissionHistory:add'],
        edit: ['admin', 'inBoundMissionHistory:edit'],
        del: ['admin', 'inBoundMissionHistory:del']
      },
      rules: {
      },
      queryTypeOptions: [
        { key: 'palletCode', display_name: '载盘编码' },
        { key: 'missionCode', display_name: '任务编码' }
      ]
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped></style>
